import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import * as bodyParser from 'body-parser';
import * as compression from 'compression';
import { StatusInterceptor } from './core/StatusInterceptor';
import { NestExpressApplication } from '@nestjs/platform-express';

async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(AppModule);
  // 防止 报错 request entity too large
  app.use(bodyParser.json({ limit: '50mb' }));
  app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));
  // 统一返回0
  app.useGlobalInterceptors(new StatusInterceptor());
  // gzip压缩
  app.use(compression());
  // 启用CORS
  app.enableCors();
  // 静态目录
  app.useStaticAssets('public');
  // 全局前缀
  app.setGlobalPrefix('wando');
  await app.listen(43000);
  console.log('启动43000端口，统一前缀/wando');
}
bootstrap();
